﻿Public Partial Class Wfrm_Anular_Solicitud
    Inherits System.Web.UI.Page
     
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'session("usuario")
        btnAnular.Attributes.Add("onclick", "return confirm('¿Confirma Anular Solicitud?')")

        If Not Page.IsPostBack Then
            'txtCantidad.Attributes.Add("onkeypress", "javascript:return ValidNum(event);")
            'txtNsolicitud.Attributes.Add("onkeypress", "javascript:return ValidNum(event);")
            'Session("usu") = Session("usuario")
            ViewState("usu") = Session("usuario")
            llena_combo()
            carga_bodega()
            FK_EMPRESA()
            carga_Estado_solicitud()
            CreaDatatable()
            Panel3.Visible = False
            Panel3.UpdateAfterCallBack = True
            Carga_Datos_Usuario()
        End If
    End Sub

    Sub carga_Estado_solicitud()
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_CARGA_ESTADO"
        exec.ExecuteDataTable(rp)

        If rp.TieneDatos Then
            cmb_estado_solicitud.DataTextField = "s_texto"
            cmb_estado_solicitud.DataValueField = "id_concepto"
            cmb_estado_solicitud.DataSource = rp.DtTable
            cmb_estado_solicitud.DataBind()

            cmb_estado_solicitud.SelectedValue = "-1"
            cmb_estado_solicitud.UpdateAfterCallBack = True

        End If
    End Sub


    Sub CreaDatatable() 'JQ
        Dim Dt2 As New DataTable
        Dt2.Columns.Add("")
        Dt2.Columns.Add("nCodigo_PKI")
        Dt2.Columns.Add("Producto")
        Dt2.Columns.Add("tNombre")
        Dt2.Columns.Add("CANT_SOLICITADA")
        ViewState("DT") = Dt2
    End Sub
    Sub FK_EMPRESA()
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence

        rp.StoredProcedure = ("SP_OC_GET_FK_EMPRESA")
        rp.AddParametro(ViewState("usu"))
        exec.ExecuteDataTable(rp)

        If rp.TieneDatos Then
            ViewState("FK_EMPRESA") = rp.DtTable.Rows(0).Item(0).ToString
        End If
        If rp.Errores Then
            'erro
        Else
            'ok
        End If

    End Sub

    Sub carga_bodega()
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence

        rp.StoredProcedure = ("SP_OC_CARGA_BODEGA")
        rp.AddParametro(ViewState("usu"))
        exec.ExecuteDataTable(rp)

        If rp.TieneDatos Then
            cmbBodega.DataTextField = "DESCRIPCION"
            cmbBodega.DataValueField = "ID_BODEGA"
            cmbBodega.DataSource = rp.DtTable
            cmbBodega.DataBind()
            cmbBodega.UpdateAfterCallBack = True
        End If
    End Sub

    Sub llena_combo()
        ' If ViewState("Vista") Is Nothing Then
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence

        If Rad_orden.SelectedValue = "tnombre1" Then
            rp.StoredProcedure = ("SP_OC_PRODUCTOS")
        Else
            rp.StoredProcedure = ("SP_OC_PRODUCTOS_cod")
        End If

        exec.ExecuteDataTable(rp)

        If rp.TieneDatos Then
            'Dim Vista As New DataView(rp.DtTable)
            'ViewState("Vista") = rp.DtTable
            'Vista.Sort = Me.Rad_orden.SelectedValue '& " desc"

            cmbProducto.DataTextField = "tnombre"
            cmbProducto.DataValueField = "nCodigo_PKI"
            cmbProducto.DataSource = rp.DtTable
            cmbProducto.DataBind()
            cmbProducto.UpdateAfterCallBack = True
        End If
        'Else
        'Dim Vista As New DataView(ViewState("Vista"))
        'Vista.Sort = Me.Rad_orden.SelectedValue '& " desc"

        'cmbProducto.DataTextField = "tnombre"
        'cmbProducto.DataValueField = "nCodigo_PKI"
        'cmbProducto.DataSource = Vista
        'cmbProducto.DataBind()
        'cmbProducto.UpdateAfterCallBack = True
        'End If
    End Sub

    Private Function SumarProducto(ByVal codProducto As String) As Decimal 'JQ
        Dim i As Integer
        For i = 0 To DataGrid2.Items.Count - 1
            If codProducto = DataGrid2.Items(i).Cells(1).Text Then
                Return DirectCast(DirectCast(DataGrid2.Items(i).Cells(4).FindControl("Label5"), System.Web.UI.Control), Label).Text

            End If
        Next
        Return 0
    End Function

    Sub AgregaProducto(ByVal fk_solicitud As String, ByVal fk_producto As String, ByVal Cant_sol As Decimal) 'JQ

        Dim exec As New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence

        rp.StoredProcedure = "SP_OC_ADD_SOLICITUD_PRODUCTO"

        rp.AddParametro(fk_solicitud)
        rp.AddParametro(fk_producto)
        rp.AddParametro(Cant_sol)
        rp.AddParametro(ViewState("usu"))

        exec.ExecuteNonQuery(rp)
        exec.Commit()

        If rp.Errores Then

        End If
    End Sub
    Sub ActualizaProducto(ByVal fk_solicitud As String, ByVal fk_producto As String, ByVal Cant_sol As Decimal) 'JQ

        Dim exec As New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence

        rp.StoredProcedure = "SP_OC_UPDATE_SOLICITUD_PRODUCTO"

        rp.AddParametro(fk_solicitud)
        rp.AddParametro(fk_producto)
        rp.AddParametro(Cant_sol)
        rp.AddParametro(ViewState("usu"))
        rp.AddParametro(cmbBodega.SelectedValue)

        exec.ExecuteNonQuery(rp)
        exec.Commit()

        If rp.Errores Then
            Mensaje(rp.MensajeError)
        End If
    End Sub

    Sub GetProductosSolicitud()  'JQ      
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_GET_SOLICITUD_PRODUCTO"
        rp.AddParametro(txtSolicitud.Text)
        exec.ExecuteDataTable(rp)



        ViewState("DT") = rp.DtTable
        If rp.TieneDatos Then
            lbl_nro_productos.Text = DataGrid2.Items.Count
            lbl_nro_productos.UpdateAfterCallBack = True


            ViewState("datos") = rp.DtTable.Rows(0).Item(4).ToString
            DataGrid2.DataSource = rp.DtTable
            DataGrid2.DataBind()
            DataGrid2.UpdateAfterCallBack = True
        Else
            lbl_nro_productos.Text = 0
            lbl_nro_productos.UpdateAfterCallBack = True

            DataGrid2.DataSource = Nothing
            DataGrid2.DataBind()
            DataGrid2.UpdateAfterCallBack = True
        End If

    End Sub
    Protected Sub DataGrid2_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DataGrid2.SelectedIndexChanged

        'If btnAgrega.Visible = False Then
        '    Exit Sub
        'End If


        Dim exec As New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        If Val(txtSolicitud.Text) = 0 Then
            Dim i As Integer
            For i = 0 To ViewState("DT").Rows.Count - 1
                If ViewState("DT").Rows(i).Item(1) = DataGrid2.SelectedItem.Cells(1).Text Then  'cmbProducto.SelectedValue Then DU
                    ViewState("DT").Rows(i).Delete()
                    Exit For
                End If
            Next

            DataGrid2.DataSource = ViewState("DT")
            DataGrid2.DataBind()
            DataGrid2.UpdateAfterCallBack = True

        Else
            'se quita fila directamente de la tabla

            For i = 0 To ViewState("DT").Rows.Count - 1
                If ViewState("DT").Rows(i).Item(0) = DataGrid2.SelectedItem.Cells(1).Text Then  'cmbProducto.SelectedValue Then DU
                    ViewState("DT").Rows(i).Delete()
                    Exit For
                End If
            Next

            'hacer sp pa eliminar de la tabla  --- parecido al update 

            rp.StoredProcedure = "SP_OC_DELETE_PRODUCTO"
            rp.AddParametro(DataGrid2.SelectedItem.Cells(1).Text)
            rp.AddParametro(DirectCast(DataGrid1.SelectedItem.Cells(0).Controls(1), Anthem.LinkButton).Text)
            'DataGrid1.SelectedItem.Cells(0).Text)
            exec.ExecuteNonQuery(rp)
            exec.Commit()
            If rp.Errores Then

            End If

            'Cargar grilla
            GetProductosSolicitud()

        End If

        Try
            lbl_nro_productos.Text = DataGrid2.Items.Count
            lbl_nro_productos.UpdateAfterCallBack = True
        Catch ex As Exception

        End Try

    End Sub

    Protected Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DataGrid1.SelectedIndexChanged
        txtSolicitud.Text = DirectCast(DataGrid1.SelectedItem.Cells(0).Controls(1), Anthem.LinkButton).Text
        txtSolicitud.UpdateAfterCallBack = True
        GetProductosSolicitud()

        cmbBodega.SelectedValue = DataGrid1.SelectedItem.Cells(3).Text
        cmbBodega.UpdateAfterCallBack = True
        cmbBodega.Enabled = False
        cmbBodega.UpdateAfterCallBack = True

        pnl_productos.Visible = True
        Panel2.Visible = True

        lblSolicitud0.Visible = True

        lblSolicitud0.UpdateAfterCallBack = True
        pnl_productos.UpdateAfterCallBack = True
        Panel2.UpdateAfterCallBack = True

        lbl_nro_solicitud.Text = txtSolicitud.Text
        lbl_nro_solicitud.UpdateAfterCallBack = True

        Try
            lbl_nro_productos.Text = DataGrid2.Items.Count
            lbl_nro_productos.UpdateAfterCallBack = True
        Catch ex As Exception

        End Try

        'CREADA()
        'ENVIADA()
        'ACEPTADA

        btnAnular.Visible = False
        If DataGrid1.SelectedItem.Cells(4).Text = 0 Or DataGrid1.SelectedItem.Cells(4).Text = 1 Or DataGrid1.SelectedItem.Cells(4).Text = 6 Then
            btnAnular.Visible = True
        End If
        btnAnular.UpdateAfterCallBack = True


        'If ViewState("datos") = "1" Then

        '    txtCantidad.ReadOnly = True
        '    txtCantidad.UpdateAfterCallBack = True
        '    ViewState("datos") = Nothing
        '    DataGrid2.Enabled = False
        '    DataGrid2.UpdateAfterCallBack = True
        '    cmbBodega.Enabled = False
        '    cmbProducto.Enabled = False
        '    cmbBodega.UpdateAfterCallBack = True
        '    cmbProducto.UpdateAfterCallBack = True
        'Else

        '    txtCantidad.ReadOnly = False
        '    txtCantidad.UpdateAfterCallBack = True
        '    ViewState("datos") = Nothing
        '    DataGrid2.Enabled = True
        '    DataGrid2.UpdateAfterCallBack = True
        '    cmbBodega.Enabled = True
        '    cmbProducto.Enabled = True
        '    cmbBodega.UpdateAfterCallBack = True
        '    cmbProducto.UpdateAfterCallBack = True
        'End If
    End Sub


    Function grabar()
        Dim exec As New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        Dim id_sol As String

        If txtSolicitud.Text <> "" Then
            ViewState("id_sol") = txtSolicitud.Text
            For i = 0 To DataGrid2.Items.Count - 1
                rp.ClearParametro()
                rp.TieneDatos = False
                rp.StoredProcedure = "SP_OC_UPDATE_SOLICITUD_PRODUCTO"
                rp.AddParametro(txtSolicitud.Text)
                rp.AddParametro(DataGrid2.Items(i).Cells(1).Text.ToString)
                rp.AddParametro(DirectCast(DirectCast(DataGrid2.Items(i).Cells(4).FindControl("Label5"), System.Web.UI.Control), Label).Text)
                rp.AddParametro(ViewState("usu"))
                rp.AddParametro(cmbBodega.SelectedValue)
                exec.ExecuteNonQuery(rp)
                If rp.Errores Then
                    Return 0
                Else
                End If
            Next
            exec.Commit()
            If rp.Errores Then
                Return 0
            Else
                Mensaje("Wfrm_CreaSolicitud", "SolAct")
            End If
            Return txtSolicitud.Text
        Else
            rp.StoredProcedure = "SP_OC_INSERT_SOLICITUD"
            rp.AddParametro(ViewState("FK_EMPRESA")) '("FK_EMPRESA") 'nClinicaID de usuario, HACER SP
            rp.AddParametro(cmbBodega.SelectedValue) '("FK_BODEGA") 'id_bodega del combobox
            rp.AddParametro(ViewState("usu")) '("FK_USUARIO_CREA") 'PONDRE Tcodigo_user_PK, FVOR REVISAR
            rp.AddParametro("0") '("ESTADO_SOL")
            exec.ExecuteScalar(rp) 'cuando queremos que devuelva un valor, el @@IDENTITY del SP.
            id_sol = rp.GetScalar
            ViewState("id_sol") = rp.GetScalar

            For i = 0 To DataGrid2.Items.Count - 1
                rp.ClearParametro()
                rp.TieneDatos = False

                rp.StoredProcedure = "SP_OC_INSERT_SOLICITUD_PRODUCTO"
                rp.AddParametro(id_sol)
                rp.AddParametro(DataGrid2.Items(i).Cells(1).Text.ToString)
                rp.AddParametro((DirectCast(DirectCast(DataGrid2.Items(i).Cells(4).FindControl("Label5"), System.Web.UI.Control), Label).Text))
                rp.AddParametro(ViewState("usu"))

                exec.ExecuteNonQuery(rp)

            Next


        End If

        If rp.Errores Then
            Return 0
        Else
            'ok
        End If


        If Not rp.Errores Then
            exec.Commit()
            'Mensaje("Wfrm_CreaSolicitud", "SolGrab")
            Return id_sol
        Else
            Mensaje(rp.MensajeError)
        End If
        Return 0

    End Function
    Sub Mensaje(ByVal Msg As String)

        If Anthem.Manager.IsCallBack Then
            Anthem.Manager.AddScriptForClientSideEval("alert('" & Msg & "')")
        Else
            Page.ClientScript.RegisterStartupScript(Me.GetType, "alertar", "<script>alert('" & Msg & "')</script>")
        End If

    End Sub

    Sub Mensaje(ByVal tbl As String, ByVal codigo As String)

        Dim mensaje As String = FuncionesGlobal.GetMensaje(tbl, codigo)


        If Anthem.Manager.IsCallBack Then
            Anthem.Manager.AddScriptForClientSideEval("alert('" & mensaje & "')")
        Else
            Page.ClientScript.RegisterStartupScript(Me.GetType, "alertar", "<script>alert('" & mensaje & "')</script>")
        End If


    End Sub
    Sub Mensaje0(ByVal tbl As String, ByVal codigo As String)

        Dim mensaje As String = FuncionesGlobal.GetMensaje(tbl, codigo)


        If Anthem.Manager.IsCallBack Then
            Anthem.Manager.AddScriptForClientSideEval("alert('" & mensaje & "')")
        Else
            Page.ClientScript.RegisterStartupScript(Me.GetType, "alertar", "<script>alert('" & mensaje & "')</script>")
        End If


    End Sub
    Sub Carga_Datos_Usuario()
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_Get_INFO_FORM"
        rp.AddParametro(ViewState("usu"))
        exec.ExecuteDataTable(rp)

        If rp.TieneDatos Then
            lbl_clinica.Text = rp.DtTable.Rows(0).Item("tNombreFantasia").ToString.Trim
            lbl_usuario.Text = rp.DtTable.Rows(0).Item("Tnombre").ToString.Trim
            lbl_fecha.Text = Now

            lbl_clinica.UpdateAfterCallBack = True
            lbl_usuario.UpdateAfterCallBack = True
            lbl_fecha.UpdateAfterCallBack = True

        End If

    End Sub
    Protected Sub btnBuscaSol_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnBuscaSol.Click
        BuscarSol()
    End Sub
    Sub BuscarSol()
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence


        If txtStartDate.Text = "" Or txtEndDate.Text = "" Or txtNsolicitud.Text <> "" Then

            If Not IsNumeric(txtNsolicitud.Text) Or txtNsolicitud.Text = "" Then
                Mensaje0("Wfrm_CreaSolicitud", "ValNumero")
                Exit Sub

            End If
            rp.StoredProcedure = "SP_OC_CONSULTA_ESTADO_SOLICITUDID"
            rp.AddParametro(txtNsolicitud.Text)
            rp.AddParametro(ViewState("usu"))

            exec.ExecuteDataTable(rp)

            If rp.TieneDatos Then
                Panel3.Visible = True
                Panel3.UpdateAfterCallBack = True
                DataGrid1.DataSource = rp.DtTable
                DataGrid1.DataBind()
                DataGrid1.UpdateAfterCallBack = True

                'For i = 0 To DataGrid1.Items.Count - 1
                '    DataGrid1.Items(i).Cells(2).Text = DataGrid1.Items(i).Cells(2).Text.Substring(6, 2) & "-" & DataGrid1.Items(i).Cells(2).Text.Substring(4, 2) & "-" & DataGrid1.Items(i).Cells(2).Text.Substring(0, 4)  'Convert.ToDateTime(DataGrid1.Items(i).Cells(1).Text).ToString("dd-MM-yyyy")
                '    DataGrid1.UpdateAfterCallBack = True
                'Next


            Else
                Mensaje0("Wfrm_CreaSolicitud", "ValNumSol")
                DataGrid1.DataSource = Nothing
                DataGrid1.DataBind()
                DataGrid1.UpdateAfterCallBack = True
            End If
        End If

        If txtNsolicitud.Text = "" And cmb_estado_solicitud.SelectedValue = "-1" Then

            If txtStartDate.Text = "" Or txtEndDate.Text = "" Then
                Mensaje0("Wfrm_CreaSolicitud", "RangoFecha")
                Exit Sub

            End If

            Dim fecha_ini As String
            Dim fecha_fin As String
            fecha_ini = Convert.ToDateTime(txtStartDate.Text).ToString("yyyyMMdd")
            fecha_fin = Convert.ToDateTime(txtEndDate.Text).ToString("yyyyMMdd")

            If fecha_ini.ToString > fecha_fin.ToString Then

                Mensaje0("Wfrm_CreaSolicitud", "ValFecha")

            End If
            rp.StoredProcedure = "SP_OC_CONSULTA_ESTADO_SOLICITUD_FECHA"
            rp.AddParametro(fecha_ini)
            rp.AddParametro(fecha_fin)
            rp.AddParametro(ViewState("usu"))
            'rp.AddParametro(cmb_estado_solicitud.SelectedValue)
            exec.ExecuteDataTable(rp)

            If rp.TieneDatos Then
                Panel3.Visible = True
                Panel3.UpdateAfterCallBack = True
                DataGrid1.DataSource = rp.DtTable
                DataGrid1.DataBind()
                DataGrid1.UpdateAfterCallBack = True

                'For i = 0 To DataGrid1.Items.Count - 1
                '    DataGrid1.Items(i).Cells(2).Text = DataGrid1.Items(i).Cells(2).Text.Substring(6, 2) & "-" & DataGrid1.Items(i).Cells(2).Text.Substring(4, 2) & "-" & DataGrid1.Items(i).Cells(2).Text.Substring(0, 4)  'Convert.ToDateTime(DataGrid1.Items(i).Cells(1).Text).ToString("dd-MM-yyyy")
                '    DataGrid1.UpdateAfterCallBack = True
                'Next

            Else
                Mensaje0("Wfrm_CreaSolicitud", "ValFecha")
                DataGrid1.DataSource = Nothing
                DataGrid1.DataBind()
                DataGrid1.UpdateAfterCallBack = True
            End If

            Exit Sub
        End If

        If txtNsolicitud.Text = "" And cmb_estado_solicitud.SelectedValue <> "" Then
            If txtStartDate.Text = "" Or txtEndDate.Text = "" Then
                Mensaje0("Wfrm_CreaSolicitud", "RangoFecha")
                Exit Sub

            End If

            Dim fecha_ini As String
            Dim fecha_fin As String
            fecha_ini = Convert.ToDateTime(txtStartDate.Text).ToString("yyyyMMdd")
            fecha_fin = Convert.ToDateTime(txtEndDate.Text).ToString("yyyyMMdd")

            If fecha_ini.ToString > fecha_fin.ToString Then

                Mensaje0("Wfrm_CreaSolicitud", "ValFecha")

            End If

            rp.TieneDatos = False
            rp.ClearParametro()
            rp.StoredProcedure = "SP_OC_CONSULTA_ESTADO_SOLICITUD_FECHA_ESTADO"
            rp.AddParametro(fecha_ini)
            rp.AddParametro(fecha_fin)
            rp.AddParametro(ViewState("usu"))
            rp.AddParametro(cmb_estado_solicitud.SelectedValue)
            exec.ExecuteDataTable(rp)

            If rp.TieneDatos Then
                Panel3.Visible = True
                Panel3.UpdateAfterCallBack = True
                DataGrid1.DataSource = rp.DtTable
                DataGrid1.DataBind()
                DataGrid1.UpdateAfterCallBack = True

                'For i = 0 To DataGrid1.Items.Count - 1
                '    DataGrid1.Items(i).Cells(2).Text = DataGrid1.Items(i).Cells(2).Text.Substring(6, 2) & "-" & DataGrid1.Items(i).Cells(2).Text.Substring(4, 2) & "-" & DataGrid1.Items(i).Cells(2).Text.Substring(0, 4)  'Convert.ToDateTime(DataGrid1.Items(i).Cells(1).Text).ToString("dd-MM-yyyy")
                '    DataGrid1.UpdateAfterCallBack = True
                'Next

            Else
                Mensaje0("Wfrm_CreaSolicitud", "ValFecha")
                DataGrid1.DataSource = Nothing
                DataGrid1.DataBind()
                DataGrid1.UpdateAfterCallBack = True
            End If
        End If

        Panel2.Visible = True

    End Sub

    Protected Sub Rad_orden_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Rad_orden.SelectedIndexChanged
        llena_combo()
    End Sub

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As EventArgs)

    End Sub

    Protected Sub btnAnular_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnAnular.Click
        Dim exec As New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence

        rp.StoredProcedure = ("SP_OC_ANULA_SOLICITUD")
        rp.AddParametro(txtSolicitud.Text)

        exec.ExecuteNonQuery(rp)
        exec.Commit()

        If rp.Errores Then
            Mensaje0("Wfrm_ConsultaSolicitud", "ErrorAnu")
            Exit Sub
        Else
            BuscarSol()
            btnAnular.Visible = False
            btnAnular.UpdateAfterCallBack = True
            Mensaje0("Wfrm_ConsultaSolicitud", "SolAnu")
        End If
    End Sub

    
End Class